//
//  HeartRateDataModel.swift
//  TimeBoat
//
//  Created by Jun on 2022/9/8.
//  Copyright © 2022 Time Boat. All rights reserved.
//

import Foundation

/// 心率
@objcMembers class HeartRateDataModel: NSObject {
    /// 心率值(次/分钟)
    @objc var heartRate: UInt32 = 0
    
    private let DATA_LEN_MAX = 4
    private let DATA_LEN_MIN = 1
    
    convenience init(buf: [UInt8]) {
        self.init()
        
        if (buf.count == DATA_LEN_MIN) {
            heartRate = UInt32(buf[0] & 0xff)
        } else if (buf.count == DATA_LEN_MAX) {
            heartRate = UInt32.toUInt32(buf: buf, offset: 0)
        }
    }
    
    @objc func toString() -> String {
        var str = self.yy_modelToJSONString()
        if nil == str {
            str = ""
        }
        
        return str!
    }
}
